<template>
  <div class="AccompanyingTelemetry">
    <!-- 浮窗，初始隐藏 -->
      <div class="overlay" hidden>
        <div class="floating-window">
          <!-- 浮窗内容 -->
        </div>
      </div>
    <a-list class="list-container" :grid="{ gutter:16, column: 4 }" :data-source="descriptionsList">
    <a-list-item slot="renderItem" slot-scope="item, index">
      <a-card :title="item.paramName+'('+item.paramCode+')'" class="itemBox">
       
        <a-tooltip placement="top">
        <template slot="title">
          <p>源码：{{item.paramOriginalValue}}</p>
          <p> 工程值：{{ item.paramParsedValue }}</p>
        </template>
          <p> 源码：{{ item.paramOriginalValue | ellipsis }}</p>
          <p> 工程值：{{ item.paramParsedValue | ellipsis }}</p>
      </a-tooltip>
        <!-- <p style="width:100%;white-space: pre-wrap;word-wrap: break-word;word-break: break-all">源码:{{ item.paramOriginalValue }}</p>
        <p style="width: ;100%">工程值:{{ item.paramParsedValue }}</p> -->
      </a-card>
    </a-list-item>
  </a-list>
    <a-descriptions v-if="false" title :column="2" class="color-des" size="small">
      <a-descriptions-item :ellipsis="true" :key="item.id" v-for="item in descriptionsList" :label="item.paramCode" style="display: ;flex">
        <span class="spanBox">
          源码:{{ item.paramOriginalValue }}
        </span>
        <span class="spanBox">
          工程值:{{ item.paramParsedValue }}
        </span>
        <!-- <span class="spanBox">
          字典值:{{ item.paramResult }}
        </span> -->

      </a-descriptions-item>
    </a-descriptions>
  </div>
</template>

<script>
// import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { httpAction, getAction } from '@/api/manage'
export default {
  name: 'AccompanyingTelemetry',
  // mixins: [JeecgListMixin],
  data() {
    return {
      descriptionsList: [],
      url: {
        list: "/telemetryInfo/nmcTelemetryInfo/queryListAll"
      }
    }
  },
  
  mounted() {
    this.gteDescriptionsList()
    document.querySelectorAll('.itemBox').forEach(item => {
      item.addEventListener('click', () => {
        // 显示浮窗
        const overlay = document.querySelector('.overlay');
        const floatingWindow = document.querySelector('.floating-window');
        floatingWindow.innerHTML = item.innerHTML; // 设置浮窗内容
        overlay.removeAttribute('hidden'); // 移除隐藏属性
      });
});
  },
    // 1、书写过滤函数
    filter: {
        ellipsis (value) {
              if (value.length > 10){
                return value.slice(0,10) + '...'
              }
              return value;
          }
      }
      ,
  methods: {
  
    // 关闭浮窗的函数
    closeFloatingWindow() {
      document.querySelector('.overlay').setAttribute('hidden', 'hidden');
    },
    gteDescriptionsList() {
      getAction(this.url.list).then(res => {
        this.descriptionsList = res.result
      })
    }


  },
}
</script>
<style lang='less' scoped>
@import '~@assets/less/common.less';
.list-container {
  // height: 150px; /* 设置固定高度 */
  // overflow/: auto; /* 超出部分滚动 */
}
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5); /* 半透明背景 */
  display: flex;
  align-items: center;
  justify-content: center;
}
 
.floating-window {
  background: white;
  padding: 20px;
  box-shadow: 0 0 10px black;
}
.spanBox {
  width: 50%;
  // overflow: e;
  display: inline-block;
}
</style>
<style>
.AccompanyingTelemetry .color-des .ant-descriptions-item {
  height: 40px !important;
  line-height: 40px !important;
}

.AccompanyingTelemetry .color-des .ant-descriptions-title {
  background: rgba(10, 44, 81, 0.6);
  height: 40px !important;
  padding-left: 20px;
  line-height: 40px !important;
  color: #b3f5ff;
}

.AccompanyingTelemetry .color-des .ant-descriptions-item-label {
  background: rgba(10, 44, 81, 0.6);
  width: 30%;
  min-width: 145px;
  height: 40px !important;
  line-height: 40px !important;
  text-align: center;
  color: #b3f5ff;
  font-size: 16px;
}

.AccompanyingTelemetry .color-des .ant-descriptions-item-content {
  height: 40px !important;
  line-height: 40px !important;
  background: linear-gradient(to right, rgba(11, 50, 85, 0.8), rgba(141, 136, 136, 0.01));
  width: 65%;
  padding: 0px 10px;
  color: #26fbf3;
  font-size: 18px;
}
</style>
